
package uk.org.cardboardbox.problemmachine;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class AssetUtils {

    public static void extractAsset(Context context, String path, File dest) {
        AssetManager am = context.getAssets();
        try {
            byte[] buff = new byte[1024];
            InputStream is = am.open(path);
            FileOutputStream fos = new FileOutputStream(dest);
            int read = 0;
            while ((read = is.read(buff)) != -1)
                fos.write(buff, 0, read);
            fos.flush();
            fos.close();
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
